package com.agriculture.monitor.controller;


import com.agriculture.monitor.base.ResultInfo;
import com.agriculture.monitor.dto.BasePage;
import com.agriculture.monitor.dto.DevicePage;
import com.agriculture.monitor.entity.Collect;
import com.agriculture.monitor.service.ICollectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2024-04-15
 */
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    ICollectService collectService;

    /**
     * 手动写入数据
     insert into t_collect(value_data,device_id, date_time)
     select  round(RAND() * 500)  , id,date_add(curdate(),interval 1 day) from t_device
     * @param basePage
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public ResultInfo<?> page(@RequestBody BasePage basePage) {
        return ResultInfo.OK(collectService.listPage(basePage));
    }

    @ApiOperation(value = "首页查询", notes = "首页查询")
    @PostMapping("/list")
    public ResultInfo<?> list(@RequestBody Collect collect) {
        return ResultInfo.OK(collectService.findList(collect));
    }
}
